/*
* 710605420@qq.com
*/
#pragma once
#include <ctime>
#include <functional>
#include <boost/coroutine2/all.hpp>
#include "YieldInstruction.h"
#include <vector>

namespace BoostCorountine2
{
	class CoroutineMathine
	{
	public:
		CoroutineMathine();
		virtual ~CoroutineMathine();
	public:
		Coroutine* StartCoroutine(Enumerator InEnumerator);
		void StopCoroutine(Coroutine* Coro);
		void StopAllCoroutine();
		bool HasCoroutines();

	protected:
		Coroutine* InsertCoroutine(Coroutine* Coro);
	protected:
		void ResumeCoroutines();
	private:
		std::vector<Coroutine*> Coroutines;
		std::vector<Coroutine*> CoroutinesCopy;
		std::unique_ptr<std::thread> Thread;
	};

}
